/* MERARY Premium B v3f — the end of the hero film. Loaded after premium-b3m.css. Only the hero is touched.
 * Motion: premium personality, one curve family, no overshoot.
 *   hold  — the open trunk is held 1.1 s while the frame drifts in by 3.5 % (ambient layer)
 *   fade  — wine-black curtain 1.7 s, sine-like in-out (primary layer)
 *   final — title rises 16 px out of a 6 px blur, then text and buttons follow 100 ms apart (secondary layer)
 *   rewind— the card leaves in 0.38 s (exits are shorter), the film returns from behind the curtain. */

.v2-hero { --vf-fade: 1700ms; --vf-in: cubic-bezier(.22, .8, .24, 1); --vf-out: cubic-bezier(.4, 0, 1, 1); --vf-curve: cubic-bezier(.45, 0, .55, 1); }

/* ---------- picture: drift + curtain ---------- */
.v2-hero__video, .v2-hero__poster { transform-origin: 50% 56%; transition: opacity .8s ease, transform 3.2s cubic-bezier(.25, .1, .25, 1); }
.v2-hero[data-phase="hold"] .v2-hero__video,
.v2-hero[data-phase="fade"] .v2-hero__video,
.v2-hero[data-phase="final"] .v2-hero__video { transform: scale(1.035); }
.v2-hero[data-phase="rewind"] .v2-hero__video { transform: none; transition: none; }

.vf-curtain {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  /* deep wine-black with the faintest memory of light where the flowers were */
  background:
    radial-gradient(54% 48% at 50% 54%, rgba(92, 28, 54, .5) 0%, rgba(92, 28, 54, .16) 48%, rgba(92, 28, 54, 0) 76%),
    #12060c;
  transition: opacity .9s var(--vf-in);
}
.v2-hero[data-phase="fade"] .vf-curtain { opacity: 1; transition: opacity var(--vf-fade) var(--vf-curve); }
.v2-hero[data-phase="final"] .vf-curtain,
.v2-hero[data-phase="rewind"] .vf-curtain { opacity: 1; transition: opacity var(--vf-fade) var(--vf-curve); }

/* film control: quiet during the film, still there on the end card as «Смотреть снова» */
.v2-hero[data-phase="fade"] .v2-film__bar, .v2-hero[data-phase="final"] .v2-film__bar { opacity: 0; }
.v2-film__bar { transition: opacity .4s ease; }

/* everything appears at once when there is nothing to animate */
.v2-hero.is-static .vf-curtain, .v2-hero.is-static .v2-hero__copy, .v2-hero.is-static .v2-hero__copy > *,
.v2-hero.is-static h1, .v2-hero.is-static .vf-quick, .v2-hero.is-static .v2-peek { transition: none !important; animation: none !important; }

/* ====================== desktop & tablet: the end card in the centre of the frame ====================== */
@media (min-width: 641px) {
  /* no text over the film any more: keep only the top and bottom shade for the header and the controls */
  .v2-hero::after {
    background:
      linear-gradient(0deg, rgba(23, 10, 16, .78) 0%, rgba(23, 10, 16, 0) 30%),
      linear-gradient(180deg, rgba(23, 10, 16, .55) 0%, rgba(23, 10, 16, 0) 18%);
  }
  .v2-hero__copy {
    left: 0; right: 0; top: 0; bottom: 0; width: auto; max-width: 1040px; margin: 0 auto;
    padding: 96px var(--gut) 112px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    pointer-events: none;
  }
  .v2-hero h1 { font-size: clamp(48px, 6.6vw, 108px); line-height: 1; }
  .v2-hero__copy p { margin: 26px auto 36px; max-width: 44ch; }
  .v2-hero__actions { justify-content: center; }
  .v2-hero__copy > * {
    animation: none; opacity: 0; transform: translateY(16px); filter: blur(6px);
    transition: opacity .38s var(--vf-out), transform .38s var(--vf-out), filter .38s var(--vf-out);
  }
  .v2-hero__actions { visibility: hidden; transition: opacity .38s var(--vf-out), transform .38s var(--vf-out), filter .38s var(--vf-out), visibility 0s .38s; }
  .v2-hero[data-phase="final"] .v2-hero__copy { pointer-events: auto; }
  .v2-hero[data-phase="final"] .v2-hero__copy > * {
    opacity: 1; transform: none; filter: none;
    transition: opacity 1s var(--vf-in), transform 1.1s var(--vf-in), filter 1s var(--vf-in);
  }
  .v2-hero[data-phase="final"] .v2-hero__copy > :nth-child(2) { transition-delay: .1s; }
  .v2-hero[data-phase="final"] .v2-hero__actions { visibility: visible; transition-delay: .2s; transition-property: opacity, transform, filter, visibility; }

  /* quick way to the collection while the film runs; it gives way to the end card (never both at once) */
  .v2-hero__side { align-items: flex-end; }
  .vf-quick {
    font-size: 14px; font-weight: 600; color: var(--champ); text-decoration: underline; text-underline-offset: 6px;
    text-decoration-color: rgba(244, 233, 227, .45); text-shadow: 0 1px 8px rgba(0, 0, 0, .6);
    transition: opacity .38s var(--vf-out), visibility 0s;
  }
  .vf-quick:hover { color: var(--rose); }
  .v2-peek { transition: opacity .38s var(--vf-out), visibility 0s; }
  .v2-hero[data-phase="fade"] .vf-quick, .v2-hero[data-phase="final"] .vf-quick, .v2-hero[data-phase="rewind"] .vf-quick,
  .v2-hero[data-phase="fade"] .v2-peek, .v2-hero[data-phase="final"] .v2-peek, .v2-hero[data-phase="rewind"] .v2-peek {
    opacity: 0; visibility: hidden; transition: opacity .38s var(--vf-out), visibility 0s .38s;
  }
}

/* ====================== phones: the title rises inside the picture; text + buttons stay below ====================== */
@media (max-width: 640px) {
  .vf-quick { display: none; }
  /* the title leaves the flow and takes the picture's place, so the first screen never changes height */
  .v2-hero__copy { position: static; text-align: center; }
  .v2-hero h1 {
    position: absolute; z-index: 3; left: var(--gut); right: var(--gut); top: 58px; height: 75vw; margin: 0;
    display: flex; align-items: center; justify-content: center; text-align: center;
    font-size: clamp(34px, 10.2vw, 44px); line-height: 1.02; pointer-events: none;
    animation: none; opacity: 0; transform: translateY(14px); filter: blur(6px);
    transition: opacity .38s var(--vf-out), transform .38s var(--vf-out), filter .38s var(--vf-out);
  }
  .v2-hero[data-phase="final"] h1 { opacity: 1; transform: none; filter: none; transition: opacity 1s var(--vf-in), transform 1.1s var(--vf-in), filter 1s var(--vf-in); }
  .v2-hero__copy p { margin: 6px auto 20px; max-width: 34ch; }
  .v2-hero__actions { justify-content: center; }
}
